@inject('appRepository', 'App\Repositories\AppRepository')
@extends('layouts.app',['navShow'=>true])
@php
    $banner = $appRepository->getContentByColumn('ContentPicture',5,'新闻页','新闻页banner');
    $guowang = $appRepository->getContentByColumn('ContentBlog',8,'新闻页','过往资讯');
@endphp
@section('title',"培优策-{$name}")
@section('content')
    @if($banner && count($banner))
        <div id="myCarousel" class="carousel slide" data-ride="carousel">
            <ol class="carousel-indicators">
                @foreach($banner as$key=> $item)
                    <li data-target="#myCarousel" data-slide-to="0" class="{{$key===0?'active':''}}"></li>
                @endforeach
            </ol>
            <div class="carousel-inner">
                @foreach($banner as $key=>$item)
                    <div class="carousel-item {{$key===0?'active':''}}">
                        <img class="img-fluid"
                             src="{{$item->content_detail->assets_path}}"
                             alt="First slide">
                        <div class="container">
                            <div class="carousel-caption text-left">
                                <h1>{{$item->title}}</h1>
                            </div>
                        </div>
                    </div>
                @endforeach
            </div>
            <a class="carousel-control-prev" href="#myCarousel" role="button" data-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                <span class="sr-only">Previous</span>
            </a>
            <a class="carousel-control-next" href="#myCarousel" role="button" data-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                <span class="sr-only">Next</span>
            </a>
        </div>

    @endif
    <div class="container py-0 my-5" >
        <div class="d-flex justify-content-center">
            <h3>{{"培优策 - {$name}"}}</h3>
        </div>
        <div class="row mt-3 picture-content-box">
            @foreach($content as $item)
                <div class="col-xl-6 col-xs-12  p-4 ">
                    <div class="media">
                        <img  src="{{$item->content_detail->asset->path}}" class="mr-5 img-fluid">
                        <div class="media-body">
                            <a href="{{url('content',['id'=>$item->id])}}">
                                <h5 class="mt-0 picture-content-title">{{$item->title}}</h5>
                            </a>
                            {{$item->keywords}}
                        </div>
                    </div>
                    <div class="picture-bottom">
                        @php
                            $time = \Carbon\Carbon::parse($item->created_at);
                        @endphp
                        <div class="d-flex justify-content-between time-box ml-3">
                            <p class="left-body">
                                <span  class="day">{{$time->month}}-{{$time->day}}</span>
                                <span class="middle">/</span>
                                <span class="year">{{$time->year}}</span>
                                <span class="time">{{sprintf("%02d", $time->hour)}}:{{sprintf("%02d",$time->minute)}}</span>
                            </p>
                            <p class="right-body">
                                <i class="fa fa-eye"></i>
                                <span class="ml-2">{{$item->view_count}}</span>
                            </p>
                        </div>
                    </div>
                </div>
            @endforeach
        </div>
        {{ $content->links('layouts.page') }}
        <div class="d-flex justify-content-center mt-5">
            <h3>往期资讯</h3>
        </div>
        <div class="row mt-4 guowang-list mt-5 ml-1">
            @foreach($guowang as $item)
                <div class=" media mb-3 pb-1 col-6 ">
                    <img src="{{$item->content_detail->asset->path}}"  class="img-fluid" alt="">
                    <div class="media-body col-8  pl-5 ">
                        <a href="{{url('content',['id'=>$item->id])}}" target="_blank">
                            <h4 class="news-title text-o">{{$item->title}}</h4>
                        </a>
                        {{$item->keywords}}
                        <div class=" mt-1">
                            <p>{{$time->year}}/{{$time->month}}/{{$time->day}}
                                &nbsp;&nbsp;&nbsp;{{$time->hour}}:{{$time->minute}}
                                &nbsp;&nbsp;
                                &nbsp;&nbsp;&nbsp;&nbsp;
                                &nbsp;&nbsp;&nbsp;
                                <span><i class="fa fa-eye"></i>&nbsp;&nbsp;&nbsp;{{$item->view_count}}</span></p>
                        </div>
                    </div>
                </div>
            @endforeach
        </div>
    </div>


@endsection